#include<sqlite3.h>
#include<iostream>
#include<string>
#include<vector>

class Sqlite{
    typedef int(*CallBack)(void*,int,char**,char**);
    public:
    Sqlite(std::string file):_file(file),_header(nullptr){}
    bool open(int flags=SQLITE_OPEN_FULLMUTEX){
        int ret=sqlite3_open_v2(_file.c_str(),&_header,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|flags,nullptr);
        if(ret!=SQLITE_OK)
        {
            std::cout<<"打开文件失败";
            return false;
        }
        return true;
    }
    bool exec(const std::string&sql,CallBack cb,void*arg){
        int ret=sqlite3_exec(_header,sql.c_str(),cb,arg,nullptr);
        if(ret!=SQLITE_OK)
        {
            std::cout<<"执行语句失败"<<std::endl;
            return false;
        }
        return true;
    }
    void close(){
        if(_header)sqlite3_close(_header);
    }
    private:
    sqlite3*_header;
    std::string _file;
};